<%--
  Created by IntelliJ IDEA.
  User: maicss
  Date: 2022/5/1
  Time: 下午6:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理系统首页</title>
    <link href="style/pages.css" type="text/css" rel="stylesheet">
    <link href="style/home.css" type="text/css" rel="stylesheet">
</head>
<body>
    <div class="box" id="banner">
        <h2>河北工业大学<span>廊坊分校</span></h2>
        <p>2022年Web课程设计作品</p>
        <p>小组成员：刘风琛、马佳乐、乔梁、顾璇、龚文涛、王欣然</p>
    </div>
    <div class="box" id="invitationCodeBox">
        <h3>邀请码<button><span class="iconfont">&#xe68a;</span></button></h3>
        <span id="invitationCode"></span>
    </div>
    <script>
        let invitationCode = document.getElementById("invitationCode")
        let updateButton = document.getElementById("invitationCodeBox").getElementsByTagName("button")[0]
        updateButton.addEventListener("pointerdown",updateTransitionEnd)
        updateButton.addEventListener("click",updateInvitationCode)
        function updateTransitionEnd() {
            updateButton.style.transition = "none"
            updateButton.style.transform = "rotate(0deg)"
        }
        function updateInvitationCode(){
            updateButton.style.transition = "transform 1s ease-out"
            updateButton.style.transform = "rotate(-360deg)"
            invitationCode.innerText = "******"
            const Http = new XMLHttpRequest();
            const url='../userServlet?type=invitationCode';
            Http.open("GET", url);
            Http.send();
            Http.onreadystatechange = (e) => {
                if (Http.status===505) {
                    alert("登录已超时，请重新登录")
                    top.location.replace("../login.jsp")
                }else {
                    invitationCode.innerText = Http.responseText
                }
            }
        }
        updateInvitationCode()
    </script>
</body>
</html>
